package com.partsoft.dits.log;

import java.io.IOException;
import java.io.Serializable;

import org.apache.commons.io.IOUtils;

@SuppressWarnings("serial")
public abstract class AbstractLogAttachment implements LogAttachment, Serializable, Cloneable {
	
	private String name;
	
	public AbstractLogAttachment(){}
	
	public AbstractLogAttachment(String name) {
		setName(name);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public byte[] getBytes() throws IOException {
		return IOUtils.toByteArray(getInputStream());
	}
	
	public AbstractLogAttachment clone() {
		try {
			return (AbstractLogAttachment) super.clone();
		} catch (CloneNotSupportedException e) {
			return null;
		}
	}
	
}
